home *** CD-ROM | disk | FTP | other *** search
/ Freelog 125 / Freelog_MarsAvril2015_No125.iso / Musique / Quod Libet / quodlibet-3.3.0-portable.exe / quodlibet-3.3.0-portable / data / bin / quodlibet / config.pyc (.txt) < prev    next >
Python Compiled Bytecode  |  2014-12-31  |  8KB  |  253 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.7)
  3.  
  4. import shutil
  5. import const
  6. from quodlibet.util.config import Config, Error
  7. AUTO_ENABLED_PLUGINS = [
  8.     'Shuffle Playlist',
  9.     'Remove Playlist Duplicates']
  10. INITIAL = {
  11.     'header_maps': { },
  12.     'player': {
  13.         'time_remaining': 'false',
  14.         'replaygain': 'on',
  15.         'fallback_gain': '0.0',
  16.         'pre_amp_gain': '0.0',
  17.         'backend': 'gstbe',
  18.         'gst_pipeline': '',
  19.         'gst_buffer': '1.5',
  20.         'gst_device': '',
  21.         'gst_disable_gapless': 'false' },
  22.     'library': {
  23.         'exclude': '',
  24.         'refresh_on_start': 'true' },
  25.     'memory': {
  26.         'song': '',
  27.         'seek': '0',
  28.         'volume': '1.0',
  29.         'browser': 'PanedBrowser',
  30.         'songlist': 'true',
  31.         'queue': 'false',
  32.         'shufflequeue': 'false',
  33.         'sortby': '0album',
  34.         'order': 'inorder',
  35.         'order_shuffle': 'shuffle',
  36.         'shuffle': 'false',
  37.         'plugin_selection': '',
  38.         'column_widths': '',
  39.         'column_expands': '' },
  40.     'browsers': {
  41.         'query_text': '',
  42.         'panes': '~people\t<~year|[b][i]<~year>[/i][/b] - ><album>',
  43.         'pane_selection': '',
  44.         'pane_wide_mode': '0',
  45.         'background': '',
  46.         'albums': '',
  47.         'album_sort': '0',
  48.         'album_covers': '1',
  49.         'album_substrings': '1',
  50.         'collection_headers': '~people 0',
  51.         'radio': '',
  52.         'rating_click': 'true',
  53.         'rating_confirm_multiple': 'false',
  54.         'cover_size': '-1',
  55.         'search_limit': 'false' },
  56.     'settings': {
  57.         'scan': '',
  58.         'jump': 'true',
  59.         'default_rating': '0.5',
  60.         'ratings': '4',
  61.         'bayesian_rating_factor': '0.0',
  62.         'rating_symbol_full': '\xe2\x98\x85',
  63.         'rating_symbol_blank': '\xe2\x98\x86',
  64.         'repeat': 'false',
  65.         'disable_hints': 'false',
  66.         'eager_search': 'true' },
  67.     'rename': {
  68.         'spaces': 'false',
  69.         'windows': 'true',
  70.         'ascii': 'false' },
  71.     'tagsfrompath': {
  72.         'underscores': 'false',
  73.         'titlecase': 'false',
  74.         'split': 'false',
  75.         'add': 'false' },
  76.     'plugins': {
  77.         'active_plugins': '\n'.join(AUTO_ENABLED_PLUGINS),
  78.         'default_max_plugin_invocations': 30 },
  79.     'editing': {
  80.         'split_on': '/ & ,',
  81.         'id3encoding': '',
  82.         'human_title_case': 'true',
  83.         'save_to_songs': 'true',
  84.         'save_email': const.EMAIL,
  85.         'alltags': 'true',
  86.         'auto_save_changes': 'false',
  87.         'default_tags': '' },
  88.     'albumart': {
  89.         'round': 'true',
  90.         'prefer_embedded': 'false',
  91.         'force_filename': 'false',
  92.         'filename': 'folder.jpg' } }
  93. _config = Config(version = 0)
  94. options = _config.options
  95. get = _config.get
  96. getboolean = _config.getboolean
  97. getint = _config.getint
  98. getfloat = _config.getfloat
  99. getstringlist = _config.getstringlist
  100. setstringlist = _config.setstringlist
  101. set = _config.set
  102. setdefault = _config.setdefault
  103. write = _config.write
  104. reset = _config.reset
  105. add_section = _config.add_section
  106. has_option = _config.has_option
  107. remove_option = _config.remove_option
  108. register_upgrade_function = _config.register_upgrade_function
  109.  
  110. def init(filename = None, initial = None):
  111.     if not _config.is_empty():
  112.         raise ValueError('config initialized twice without quitting: %r' % _config.sections())
  113.     if initial is None:
  114.         initial = INITIAL
  115.     for section, values in initial.iteritems():
  116.         _config.add_section(section)
  117.         for key, value in values.iteritems():
  118.             _config.set_inital(section, key, value)
  119.         
  120.     
  121.     if filename is not None:
  122.         
  123.         try:
  124.             _config.read(filename)
  125.         except (Error, EnvironmentError):
  126.             print_w('Reading config file %r failed.' % filename)
  127.             
  128.             try:
  129.                 shutil.copy(filename, filename + '.not-valid')
  130.             except EnvironmentError:
  131.                 pass
  132.             
  133.  
  134.         
  135.  
  136.  
  137.  
  138. def save(filename):
  139.     '''Writes the active config to filename, ignoring all possible errors'''
  140.     print_d('Writing config...')
  141.     
  142.     try:
  143.         _config.write(filename)
  144.     except EnvironmentError:
  145.         print_w('Unable to write config.')
  146.  
  147.  
  148.  
  149. def quit():
  150.     '''Clears the active config'''
  151.     _config.clear()
  152.  
  153.  
  154. def state(arg):
  155.     return _config.getboolean('settings', arg)
  156.  
  157.  
  158. class RatingsPrefs(object):
  159.     '''
  160.     Models Ratings settings as configured by the user, with caching.
  161.     '''
  162.     
  163.     def __init__(self):
  164.         self._RatingsPrefs__number = None
  165.         self._RatingsPrefs__default = None
  166.         self._RatingsPrefs__full_symbol = None
  167.         self._RatingsPrefs__blank_symbol = None
  168.  
  169.     
  170.     def precision(self):
  171.         '''Returns the smallest ratings delta currently configured'''
  172.         return 1 / self.number
  173.  
  174.     precision = property(precision)
  175.     
  176.     def number(self):
  177.         if self._RatingsPrefs__number is None:
  178.             self._RatingsPrefs__number = getint('settings', 'ratings')
  179.         return self._RatingsPrefs__number
  180.  
  181.     number = property(number)
  182.     
  183.     def number(self, i):
  184.         '''The (maximum) integer number of ratings icons configured'''
  185.         self._RatingsPrefs__number = self._RatingsPrefs__save('ratings', int(i))
  186.  
  187.     number = number.setter(number)
  188.     
  189.     def default(self):
  190.         '''The current default floating-point rating'''
  191.         if self._RatingsPrefs__default is None:
  192.             self._RatingsPrefs__default = getfloat('settings', 'default_rating')
  193.         return self._RatingsPrefs__default
  194.  
  195.     default = property(default)
  196.     
  197.     def default(self, f):
  198.         self._RatingsPrefs__default = self._RatingsPrefs__save('default_rating', float(f))
  199.  
  200.     default = default.setter(default)
  201.     
  202.     def full_symbol(self):
  203.         '''The symbol to use for a full (active) rating'''
  204.         if self._RatingsPrefs__full_symbol is None:
  205.             self._RatingsPrefs__full_symbol = self._RatingsPrefs__get_symbol('full')
  206.         return self._RatingsPrefs__full_symbol
  207.  
  208.     full_symbol = property(full_symbol)
  209.     
  210.     def full_symbol(self, s):
  211.         self._RatingsPrefs__full_symbol = self._RatingsPrefs__save('rating_symbol_full', s)
  212.  
  213.     full_symbol = full_symbol.setter(full_symbol)
  214.     
  215.     def blank_symbol(self):
  216.         '''The symbol to use for a blank (inactive) rating, if needed'''
  217.         if self._RatingsPrefs__blank_symbol is None:
  218.             self._RatingsPrefs__blank_symbol = self._RatingsPrefs__get_symbol('blank')
  219.         return self._RatingsPrefs__blank_symbol
  220.  
  221.     blank_symbol = property(blank_symbol)
  222.     
  223.     def blank_symbol(self, s):
  224.         self._RatingsPrefs__blank_symbol = self._RatingsPrefs__save('rating_symbol_blank', s)
  225.  
  226.     blank_symbol = blank_symbol.setter(blank_symbol)
  227.     
  228.     def all(self):
  229.         '''Returns all the possible ratings currently available'''
  230.         return [ float(i) / self.number for i in range(0, self.number + 1) ]
  231.  
  232.     all = property(all)
  233.     
  234.     def __save(key, value):
  235.         set('settings', key, value)
  236.         return value
  237.  
  238.     __save = staticmethod(__save)
  239.     
  240.     def __get_symbol(variant = 'full'):
  241.         return get('settings', 'rating_symbol_%s' % variant).decode('utf-8')
  242.  
  243.     __get_symbol = staticmethod(__get_symbol)
  244.  
  245.  
  246. class HardCodedRatingsPrefs(RatingsPrefs):
  247.     number = int(INITIAL['settings']['ratings'])
  248.     default = float(INITIAL['settings']['default_rating'])
  249.     blank_symbol = INITIAL['settings']['rating_symbol_blank'].decode('utf-8')
  250.     full_symbol = INITIAL['settings']['rating_symbol_full'].decode('utf-8')
  251.  
  252. RATINGS = RatingsPrefs()
  253.